package com.blog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class HelloController {
    @RequestMapping("")
    public String index(HttpServletRequest request){
        request.setAttribute("name","这里是模板哦");
        return "index";
    }

    @RequestMapping("/view")
    public ModelAndView index(){
        ModelAndView result = new ModelAndView("index");
        result.addObject("name","这里是另一个渲染方式哦");
        return result;
    }

    @RequestMapping("map")
    public String indexpage(ModelMap map){
        map.addAttribute("name","这里是modelMap的渲染方式");
        return "index";
    }
}
